using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class BudgetMap : EntityTypeConfiguration<Budget>
    {
        public BudgetMap()
        {
            // Primary Key
            this.HasKey(t => new { t.BDGTCAT, t.ACCT, t.bdgtYear });

            // Properties
            this.Property(t => t.BDGTCAT)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.ACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.bdgtYear)
                .IsRequired()
                .HasMaxLength(4);

            // Table & Column Mappings
            this.ToTable("Budget");
            this.Property(t => t.PD1).HasColumnName("PD1");
            this.Property(t => t.PD2).HasColumnName("PD2");
            this.Property(t => t.PD3).HasColumnName("PD3");
            this.Property(t => t.PD4).HasColumnName("PD4");
            this.Property(t => t.PD5).HasColumnName("PD5");
            this.Property(t => t.PD6).HasColumnName("PD6");
            this.Property(t => t.PD7).HasColumnName("PD7");
            this.Property(t => t.PD8).HasColumnName("PD8");
            this.Property(t => t.PD9).HasColumnName("PD9");
            this.Property(t => t.PD10).HasColumnName("PD10");
            this.Property(t => t.PD11).HasColumnName("PD11");
            this.Property(t => t.PD12).HasColumnName("PD12");
            this.Property(t => t.PD13).HasColumnName("PD13");
            this.Property(t => t.THISPD).HasColumnName("THISPD");
            this.Property(t => t.BUDYTD).HasColumnName("BUDYTD");
            this.Property(t => t.USDYTD).HasColumnName("USDYTD");
            this.Property(t => t.BDGTCAT).HasColumnName("BDGTCAT");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.cstctrid).HasColumnName("cstctrid");
            this.Property(t => t.bdgtYear).HasColumnName("bdgtYear");

            // Relationships
            this.HasRequired(t => t.Acct1)
                .WithMany(t => t.Budgets)
                .HasForeignKey(d => d.ACCT);
            this.HasOptional(t => t.Cstctr)
                .WithMany(t => t.Budgets)
                .HasForeignKey(d => d.cstctrid);

        }
    }
}
